
// 验证码倒计时
var timer,count=60,iniCount;
var flag = false;
function getCodeNum(){
    flag = true;
    var phone_num   = $("#phone").val();
    $.ajax({
        type: "post",
        //dataType:"text",
        url: '/Login/sendMsg',
        data: {
            phone: phone_num,
            tag: 1
        },
        success: function (data) {
            data = JSON.parse(data);
            if (data.status == "0") {
                layer.msg(data.info, {icon: 2});
                flag = false;
                return false;
            } else {
                layer.msg('验证码已发送，请注意查收');
                }
                iniCount = count;
                $(".get-code").attr("disabled", true).css('background', "#ff0000").css('color', '#fff');
                $(".get-code").val("倒计时" + iniCount + "s");
                timer = window.setInterval(serRemainTime, 1000);
            }
            ,
            error:function (msg) {
                layer.msg('发送失败', {icon: 2});
            }
        });
}

//倒计时函数
function serRemainTime(){
    if(iniCount==0){
        window.clearInterval(timer);
        $(".get-code").removeAttr('disabled').css('background','#e00012').css('color','#fff');
        $(".get-code").text('重新发送');
        flag   =  false;
    }else{
        iniCount--;
        $(".get-code").text('倒计时'+iniCount+"s")
    }
}

$(".get_yzm").click(function(){
    if(flag)  return false;
    var phone_num = $("#phone").val();
    if(phone_num == '' ) {
        layer.msg('请填写手机号码',{icon:2});
    } else {
        var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
        if (!myreg.test($("#phone").val())) {
            layer.msg('手机号码错误！',{icon:2});
        } else {
            getCodeNum();
        }
    }
})

function validate() {
    var pwd1 = document.getElementById("password").value;
    var pwd2 = document.getElementById("confirm_password").value;
    <!-- 对比两次输入的密码 -->
    if(pwd1 == pwd2) {
        document.getElementById("tishi").innerHTML="<font color='green'>两次密码相同</font>";
        document.getElementById("submit").disabled = false;
    }
    else {
        document.getElementById("tishi").innerHTML="<font color='red'>两次密码不一致</font>";
        document.getElementById("submit").disabled = true;
    }
}
